package com.google.code.dweibo.core.topic;

import java.util.List;

import com.google.code.dweibo.core.auth.LoginService;
import com.google.code.dweibo.core.auth.LoginType;
import com.google.code.dweibo.util.WeiboServiceFactory;

import weibo4j.Comments;
import weibo4j.Timeline;
import weibo4j.model.Comment;
import weibo4j.model.Status;

public class SinaTopicViewService {
	private LoginService loginService;
	
	public SinaTopicViewService() throws Exception{
		loginService = WeiboServiceFactory.getLoginService(LoginType.SINA);
		if(!loginService.isLogin()){
			loginService.login(loginService.getPinCode());
		}
	}
	
	/** return all the comments to me
	 * 
	 * @return
	 * @throws Exception
	 */
	public List<Comment> viewCommentsToMe() throws Exception{
		if(!loginService.isLogin()){
			loginService.login(loginService.getPinCode());
		}
		return Comments.getCommentToMe();
	}
	
	/** return all the comments by me
	 * 
	 * @return
	 * @throws Exception
	 */
	
	public List<Comment> viewCommentsByMe() throws Exception{
		if(!loginService.isLogin()){
			loginService.login(loginService.getPinCode());
		}
		return Comments.getCommentByMe();
	}
	
	/**Return the latest weibo sent by me and those guys the user follow
	 * 
	 * @return
	 * @throws Exception
	 */
	
	public List<Status> viewStatus() throws Exception{
		if(!loginService.isLogin()){
			loginService.login(loginService.getPinCode());
		}
		Timeline tm = new Timeline();
		return tm.getHomeTimeline();
	}
}	
